using System.Collections.Generic;
using UnityEngine;

namespace RecommendedProduct
{
	public class SelectHandlerRandom : SelectHandlerAbstract
	{
		public override List<Product> GetProduct(List<Product> products)
		{
			List<Product> list = new List<Product>();
			if (products.Count == 0)
			{
				return list;
			}
			List<Product> list2 = new List<Product>();
			foreach (Product product in products)
			{
				if (MarketController.CanBuyProduct(product))
				{
					list2.Add(product);
				}
			}
			if (list2.Count <= _count)
			{
				return list2;
			}
			for (int i = 0; i < _count; i++)
			{
				int index = Random.Range(0, list2.Count);
				list.Add(list2[index]);
				list2.Remove(list2[index]);
			}
			list.Sort((Product x, Product y) => x.sortWeight.CompareTo(y.sortWeight));
			return list;
		}
	}
}
